//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.common.base;

public class Result<T> {
    private boolean success;
    private int code;
    private String message;
    private T data;

    private Result() {
    }

    public static <T> Result<T> success(int resultCode, T data) {
        return builder().success(true).code(resultCode).data(data).build();
    }

    public static <T> Result<T> error(int resultCode, String i18nMessage) {
        return builder().code(resultCode).success(false).message(i18nMessage).build();
    }

    public boolean isSuccess() {
        return this.success;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public T getData() {
        return this.data;
    }

    public static ResultBuilder builder() {
        return new ResultBuilder();
    }

    public String toString() {
        return "{\nsuccess: " + this.success + ",\ncode: " + this.code + ",\nmessage: " + this.message + ",\ndata: " + this.data + '}';
    }

    public static final class ResultBuilder<T> {
        private boolean success;
        private int code;
        private String message;
        private T data;

        private ResultBuilder() {
        }

        public ResultBuilder success(boolean success) {
            this.success = success;
            return this;
        }

        public ResultBuilder code(int code) {
            this.code = code;
            return this;
        }

        public ResultBuilder message(String message) {
            this.message = message;
            return this;
        }

        public ResultBuilder data(T data) {
            this.data = data;
            return this;
        }

        public Result build() {
            Result result = new Result();
            result.message = this.message;
            result.data = this.data;
            result.success = this.success;
            result.code = this.code;
            return result;
        }
    }
}
